#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
using pp = pair<ll, ll>;
ll n, k;

int main()
{
    cin >> n >> k;
    vector<int>a(n, 0);
    vector<int>b(n, 0);
    for (auto& ch : a)cin >> ch;
    for (auto& ch : b)cin >> ch;
    vector<pp>ret;
    for (int i = 0; i < n; i++)
    {
        ret.push_back(make_pair(a[i], b[i]));
    }
    sort(ret.begin(), ret.end(), [](pp f, pp g)->bool {
        if (f.second > g.second) return true;
        else if (f.second == g.second)
        {
            return f.first < g.first;
        }
        return false;
        });
    ll ret1 = 0, ret2 = 0;
    for (int i = 0; i < k; i++)
    {
        ret1 += ret[i].first;
        ret2 += ret[i].second;
    }
    cout << ret1 << " " << ret2;
    return 0;
}